package com.csu.tour.mapper;

import com.csu.tour.entity.Complaint;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;
import org.mybatis.spring.annotation.MapperScan;

import java.time.LocalDate;
import java.util.List;

@Mapper
@MapperScan("com.example.mapper")
public interface ComplaintMapper {
    @Update("update complaint_handling set evaluation=#{evaluation} where complaint_id=#{complaintId}")
    void evaluation(int complaintId, String evaluation);

    @Update("update complaint set status_approve=#{statusApprove} where complaint_id=#{complaintId}")
    void statusApprove(int complaintId, Complaint.ComplaintStatusApprove statusApprove);

    @Insert("insert into complaint_handling(complaint_id,status) values(#{complaintId},'processing')")
    void handlingAdd(int complaintId);

    @Insert("insert into complaint(user_id,text,status_approve,date,media_url) " +
            "values(#{userId},#{text},#{statusApprove},#{date},#{mediaUrl})")
    void complaintAdd(Complaint complaint);

    @Update("update complaint_handling set handling_content=#{handlingContent},status=#{status} " +
            "where complaint_id=#{complaintId}")
    void process(int complaintId, String handlingContent, Complaint.ComplaintStatus status);

    @Update("update complaint set status_approve=#{statusApprove} where complaint_id=#{complaintId}")
    void finish(int complaintId, Complaint.ComplaintStatusApprove statusApprove);

    List<Complaint> list(Complaint.ComplaintStatus status, Complaint.ComplaintStatusApprove statusApprove,
                         LocalDate begin, LocalDate end);
}
